/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.liquidByte.trafficMustang.server.dataModel;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Alexandre
 */
@Entity
@Table(name = "tran")
public class Transacao implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "TRAN_ID")
    private Long tranId;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "TRAN_VL")
    private BigDecimal tranVl;
    @Basic(optional = false)
    @NotNull
    @Column(name = "TRAN_DT")
    @Temporal(TemporalType.TIMESTAMP)
    private Date tranDt;
    @JoinColumn(name = "TRAN_TP_ID", referencedColumnName = "TRAN_TP_ID")
    @ManyToOne(optional = false)
    private TransacaoTipo tranTpId;
    @JoinColumn(name = "TRAN_MOTV_ID", referencedColumnName = "TRAN_MOTV_ID")
    @ManyToOne(optional = false)
    private TransacaoMotivo tranMotvId;
    @JoinColumn(name = "CONTA_ID", referencedColumnName = "USR_ID")
    @ManyToOne(optional = false)
    private Conta contaId;
    @OneToOne(mappedBy = "tranIdDebt")
    private Cobranca cobranca;
    @OneToOne(mappedBy = "tranIdCred")
    private Cobranca cobranca1;

    public Transacao() {
    }

    public Transacao(Long tranId) {
        this.tranId = tranId;
    }

    public Transacao(Long tranId, BigDecimal tranVl, Date tranDt) {
        this.tranId = tranId;
        this.tranVl = tranVl;
        this.tranDt = tranDt;
    }

    public Long getTranId() {
        return tranId;
    }

    public void setTranId(Long tranId) {
        this.tranId = tranId;
    }

    public BigDecimal getTranVl() {
        return tranVl;
    }

    public void setTranVl(BigDecimal tranVl) {
        this.tranVl = tranVl;
    }

    public Date getTranDt() {
        return tranDt;
    }

    public void setTranDt(Date tranDt) {
        this.tranDt = tranDt;
    }

    public TransacaoTipo getTranTpId() {
        return tranTpId;
    }

    public void setTranTpId(TransacaoTipo tranTpId) {
        this.tranTpId = tranTpId;
    }

    public TransacaoMotivo getTranMotvId() {
        return tranMotvId;
    }

    public void setTranMotvId(TransacaoMotivo tranMotvId) {
        this.tranMotvId = tranMotvId;
    }

    public Conta getContaId() {
        return contaId;
    }

    public void setContaId(Conta contaId) {
        this.contaId = contaId;
    }

    public Cobranca getCobranca() {
        return cobranca;
    }

    public void setCobranca(Cobranca cobranca) {
        this.cobranca = cobranca;
    }

    public Cobranca getCobranca1() {
        return cobranca1;
    }

    public void setCobranca1(Cobranca cobranca1) {
        this.cobranca1 = cobranca1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tranId != null ? tranId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Transacao)) {
            return false;
        }
        Transacao other = (Transacao) object;
        if ((this.tranId == null && other.tranId != null) || (this.tranId != null && !this.tranId.equals(other.tranId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.liquidByte.trafficMustang.server.dataModel.Transacao[ tranId=" + tranId + " ]";
    }
    
}
